# 2024/1/30 19:43 HFL
import json
import re

import requests

from common.AMD5 import Bmd5

def test_apichandao():
    url = 'http://192.168.12.7:8080/zentao/user-login.html'

    s = requests.session()
    rr = s.get(url=url)
    verfify=re.findall("name='verifyRand' id='verifyRand' value='(.*?)'",rr.text)
    print(verfify[0])

    password = 'admin123.'
    frit = Bmd5(password)
    mity = Bmd5(frit+verfify[0])
    print(mity)
    data={'account':'admin',
          'password':mity,  # b3490f85cf297f58c03767578aafdbc6
          'passwordStrength':1,
          'referer':'/pro/',
          'verifyRand':verfify[0],
          'keepLogin':0
          }
    res = s.post(url=url,data=data)
    print(res.text)

    rrs = s.post(url='http://192.168.12.7:8080/zentao/my/')

    if 'admin' in rrs.text:
        print('登录成功')
    else:
        print('登录失败')


